from fastapi import APIRouter, Depends

from sqlalchemy import desc, select, func
from sqlalchemy.orm import Session

from apis.deps import get_db
from models import TestDetail

router = APIRouter()


@router.get("getTestDetail", summary="根据test_report_id查询用例组测试详情")
async def get_test_detail(test_report_id: str, db: Session = Depends(get_db)):
    """
    根据testDetail_id查询用例组测试详情
    """
    test_detail_arr_sql = await db.execute(select(TestDetail).where(TestDetail.test_report_id == test_report_id))
    test_detail_arr = test_detail_arr_sql.scalars().all()
    return {"code": 200, "message": f"查询测试报告id为{test_report_id}的测试详情成功", "data": {"list": test_detail_arr}}
